from .mysqlconn import conn
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer

from ..chatterbot  import ChatBot
from ..trainers import ListTrainer
from pymongo import MongoClient



def sel():
    sql = " select g.greetingques,g.greetingid from zy_robot_greeting g "
    seq = conn.mysql_sel(sql)
    return seq

database_uri=MongoClient('mongodb://lzj:Haitang110@101.200.33.177:52726/')


bot = ChatBot(
        'allgreeting',
        storage_adapter="chatterbot.storage.MongoDatabaseAdapter",
        database='greeting2',
        database_uri=database_uri,
        read_only=True
    )

#bot.set_trainer(ListTrainer)
     #   bot.train(word_lst)


def get():
    seq = sel()
    for i in seq:
        bot.set_trainer(ListTrainer)
        bot.train([i[0],i[1]])
        

get()